package cn.tedu.basic;
/**本类用于数据类型转换
 * 1.byte-1,short-2,char-2,int-4,long-8,float-4,double-8*/
public class TestTypeChange {
    public static void main(String[] args) {
        byte a = 10;
        short b = a;
        int c = 1;
        long d = c;
        float f = 3.14F;
        double e = f;

        long g = 1234322123L;
        float h= g;

        char i = 'a';
        int j = i;//97

        int a1 = 1;
        byte b1 = 2;
//        byte c1 = a1+b1;//报错，int类型byte接不了
        byte c1 = (byte)(a1+b1);//强制类型转换

        byte d1 =(byte)128;
        System.out.println(d1);//-128,强制类型转换要在小类型的范围内，否则会发生数据溢出

        short e1 = 'a';
        char f1 = 120;
        System.out.println(e1);//97
        System.out.println(f1);//'x'

        float h1 = 324.23F;
        int i1 = (int) h1;
        System.out.println(i1);
    }
}
